﻿
// 2023/2/28: 首个版本
// 2023/7/6: 使用resizeYuv420Quarter

#ifndef SWSCALE_CPU_H_
#define SWSCALE_CPU_H_

#include "spadas.h"
#include "NextCompatibleImage.h"

namespace videonext
{
	using namespace spadas;

	class SWScaleConverterBGRYUV
	{
	public:
		SWScaleConverterBGRYUV();
		Bool open(Size2D targetSize);
		void close();
		// input: ImagePointerColor or IplImageColor, output: renew AVFrameYUV420P
		Bool convert(CompatibleImage src, CompatibleImage& dst);

	private:
		Pointer bgr2yuv420p;
		Size2D size;
	};

	class SWScaleConverterYUVBGR
	{
	public:
		SWScaleConverterYUVBGR();
		Bool open(Size2D targetSize);
		void close();
		// input: AVFrameYUV420P, output: renew ImagePointerColor
		Bool convert(CompatibleImage src, CompatibleImage& dst);

	private:
		Pointer yuv420p2bgr;
		Size2D size;
	};

	class SWScaleResizerYUV
	{
	public:
		SWScaleResizerYUV();
		Bool open(Size2D srcSize, Size2D dstSize);
		void close();
		// input: AVFrameYUV420P, output: renew AVFrameYUV420P
		Bool resize(CompatibleImage src, CompatibleImage& dst, Bool canRefer);

	private:
		Pointer yuvResizer;
		Size2D srcSize, dstSize;
	};
}

#endif
